﻿//////////////////////////////////////////////////////////////////////////////////////
///// Crossroad.cs                                                     /////
///// 갈림길인 경우                                                    /////
//////////////////////////////////////////////////////////////////////////////////////
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Input.Touch;
using Microsoft.Xna.Framework.Media;

namespace Pyramid_Game
{
    public class Crossroad : GameScreen
    {
        #region Declarations
        
        Texture2D crossroadTexture;

        #endregion

        #region Load
        
        public Crossroad()  {   }
        public override void LoadContent(ContentManager content)
        {
            crossroadTexture = content.Load<Texture2D>("Texture/fork");
        }

        #endregion

        #region Update & Draw

        public override void Update(Touch touch, GameTime gameTime)
        {
            foreach (GestureSample gesture in touch.Gestures)
            {
                if (gesture.GestureType == GestureType.Tap)
                {
                    Point tapLocation = new Point((int)gesture.Position.X, (int)gesture.Position.Y);

                    if (tapLocation.X > 0 &&
                        tapLocation.X < Game1.viewport.Width / 2 &&
                        tapLocation.Y > 0 &&
                        tapLocation.Y < Game1.viewport.Height)
                    {
                        Map.playerPoint = Map.floors[Map.playerPoint].LeftIndex;
                    }
                    else if (tapLocation.X > Game1.viewport.Width / 2 &&
                        tapLocation.X < Game1.viewport.Width &&
                        tapLocation.Y > 0 &&
                        tapLocation.Y < Game1.viewport.Height)
                    {
                        Map.playerPoint = Map.floors[Map.playerPoint].NextIndex;
                    }

                    screenManager.RemoveScreen(this);
                    screenManager.AddScreen(new Background());
                }
            }
        }
        public override void Draw(SpriteBatch spriteBatch, GameTime gameTime)
        {
            spriteBatch.Draw(crossroadTexture, new Rectangle(0, 0, Game1.viewport.Width, Game1.viewport.Height), Color.White);
        }

        #endregion
    }
}
